﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TMIS.BLL
{
    public class Summary
    {
        /// <summary>
        /// 获取院系名称
        /// </summary>
        /// <returns></returns>
        public string[] GetDepartment()
        {
            DAL.Department dal = DALFactory.DALFactory.CreateDepartment();
            return dal.Search();
        }
        /// <summary>
        /// 获取院系ID
        /// </summary>
        /// <param name="department"></param>
        /// <returns></returns>
        public Guid GetDepartmentID(string department)
        {
            DAL.Department dal = DALFactory.DALFactory.CreateDepartment();
            return dal.Search(department);
        }
        /// <summary>
        /// 获取年级ID
        /// </summary>
        /// <param name="grade"></param>
        /// <returns></returns>
        public Guid GetGradeID(string grade)
        {
            DAL.Grade dal = DALFactory.DALFactory.CreateGrade();
            return dal.Search(grade);
        }
        /// <summary>
        /// 检查所选院系ID号是否已经存在工作总结
        /// </summary>
        /// <param name="department">院系名称</param>
        /// <returns>如果存在返回true，不存在返回false</returns>
        public bool Check(string grade)
        {
            DAL.Summary sdal=DALFactory.DALFactory.CreateSummary();
            if (sdal.Search(this.GetGradeID(grade)))
            {
                return true;
            }
            else 
            {
                return false;
            }
        }
        /// <summary>
        /// 更新数据库中工作总结表中的信息
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="summary"></param>
        public void Update(Guid guid,Model.Summary summary)
        {
            DAL.Summary dal = DALFactory.DALFactory.CreateSummary();
            dal.Update(guid,summary);
        }
        /// <summary>
        /// 向数据库中添加新的工作总结表信息
        /// </summary>
        /// <param name="summary"></param>
        public void Add(Model.Summary summary)
        {
            DAL.Summary dal = DALFactory.DALFactory.CreateSummary();
            dal.Add(summary);
        }
        /// <summary>
        /// 获取指定ID对应的工作总结
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public Model.Summary GetSummary(Guid guid)
        {
            DAL.Summary dal = DALFactory.DALFactory.CreateSummary();
            return dal.Get(guid);
        }
        /// <summary>
        /// 获取指定ID对应的专业名称
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public string[] GetProfession(Guid guid)
        {
            DAL.Profession dal = DALFactory.DALFactory.CreateProfession();
            return dal.Search(guid);
        }
        /// <summary>
        /// 获取指定专业名称对应的ID号
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public Guid GetProfessionID(string profession)
        {
            DAL.Profession dal = DALFactory.DALFactory.CreateProfession();
            return dal.Search(profession);
        }
        /// <summary>
        /// 获取指定专业ID号对应的年级名称
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public string[] GetGrade(Guid guid)
        {
            DAL.Grade dal = DALFactory.DALFactory.CreateGrade();
            return dal.Search(guid);
        }

        internal void Insert(Model.Summary sum)
        {
            throw new NotImplementedException();
        }
    }
}
